package com.sg.service.biz.bff.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.BffAddEvaTepPlanCycleReqDto;
import com.sg.dto.biz.bff.res.BffAddEvaTepPlanCycleRespDto;
import com.sg.dto.integration.app.BatchAddEvaTepCyclePlanReqDto;
import com.sg.dto.integration.app.BatchAddEvaTepCyclePlanRespDto;
import com.sg.service.biz.bff.EvaWorkExecutionService;
import com.wicket.okrapp.integration.EvaWorkExecutionService;
import com.wicket.okrapp.integration.OffStateService;
import com.wicket.okrbff.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class EvaWorkExecutionServiceImpl implements EvaWorkExecutionService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.app.EvaWorkExecutionService fwAppEvaWorkExecutionClient;
    @Resource
    com.sg.service.biz.app.OffStateService fwAppOffStateClient;

    /**
     * B3-3新增评价模板安排周期相关(管理)[3099]
     * gen by moon at 10/19/2022, 6:44:40 AM
     */
    @Trace(operationName = "B3-3新增评价模板安排周期相关(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddEvaTepPlanCycleRespDto addEvaTepPlanCycle(BffAddEvaTepPlanCycleReqDto reqDto) {


        //步骤0: D3-2批量增评价模板周期安排 - batchAddEvaTepCyclePlan
        BatchAddEvaTepCyclePlanRespDto batchAddEvaTepCyclePlanRespDto = null;
        BatchAddEvaTepCyclePlanReqDto batchAddEvaTepCyclePlanReqDto = new BatchAddEvaTepCyclePlanReqDto();
        if (reqDto != null) {
            batchAddEvaTepCyclePlanReqDto.setTargetId(reqDto.getTargetId());//SimpleFieldAssign//sourceId:178218_1
            batchAddEvaTepCyclePlanReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:178219_1
        }

        /*D3-2批量增评价模板周期安排[2424]   */
        Assert.isNull(batchAddEvaTepCyclePlanReqDto.getTargetId(), "B3-3新增评价模板安排周期相关(管理)-D3-2批量增评价模板周期安排-冗余目标ID不能为空", false);
        Assert.isNull(batchAddEvaTepCyclePlanReqDto.getEvaluationTemplateId(), "B3-3新增评价模板安排周期相关(管理)-D3-2批量增评价模板周期安排-归属评价模板ID不能为空", false);
        batchAddEvaTepCyclePlanRespDto = fwAppEvaWorkExecutionClient.batchAddEvaTepCyclePlan(batchAddEvaTepCyclePlanReqDto).getData();


        BffAddEvaTepPlanCycleRespDto retData = new BffAddEvaTepPlanCycleRespDto();


        return retData;
    }
    //
}
